<?php

namespace User\Model\Entity;

class Address implements AddressInterface {
	/**
	 * @var int
	 */
	protected $id;
	
	/**
	 * @var int
	 */
	protected $userId;

	/**
	 * @var string
	 */
	protected $name;

	/**
	 * @var int
	 */
	protected $countryId;

	/**
	 * @var string
	 */
	protected $address;
	
	/**
	 * @var int
	 */
	protected $number;
	
	/**
	 * @var int
	 */
	protected $postcode;
	
	/**
	 * @var int
	 */
	protected $status;

	/**
	 * @var datetime
	 */
	protected $dateAdded;

	/**
	 * @author Tiago Peres da Silva <psilva.dev@gmail.com>
	 * @param array $data
	 */
	public function __construct($data = null) {
		if(is_array($data)) {
			$this->exchangeArray($data);
		}
	}

	/**
	 * The new array to exchange with the current object.
	 * @author Tiago Peres da Silva <psilva.dev@gmail.com>
	 * @param array $data
	 */
	public function exchangeArray(array $data) {
		$this->id			= (isset($data['user_address_id']))	? $data['user_address_id']	: null;
		$this->userId		= (isset($data['user_id']))			? $data['user_id']			: null;
		$this->name			= (isset($data['name']))			? $data['name']				: null;
		$this->countryId	= (isset($data['country_id']))		? $data['country_id']		: null;
		$this->address		= (isset($data['address']))			? $data['address']			: null;
		$this->number		= (isset($data['number']))			? $data['number']			: null;
		$this->postcode		= (isset($data['postcode']))		? $data['postcode']			: null;
		$this->status		= (isset($data['status']))			? $data['status']			: null;
		$this->dateAdded	= (isset($data['date_added']))		? $data['date_added']		: null;
	}

	/**
	 * A copy of the array, or array of public properties if ArrayIterator refers to an object.
	 * @author Tiago Peres da Silva <psilva.dev@gmail.com>
	 * @return array
	 */
	public function getArrayCopy() {
		return get_object_vars($this);
	}

	/**
	 * @return int
	 */
	public function getId() {
		return $this->id;
	}

	/**
	 * @param int $id
	 * @return Address
	 */
	public function setId($id) {
		$this->id = $id;
		return $this;
	}
	
	/**
	 * @return int
	 */
	public function getUserId() {
		return $this->userId;
	}

	/**
	 * @param int $userId
	 * @return Address
	 */
	public function setUserId($userId) {
		$this->userId = $userId;
		return $this;
	}

	/**
	 * @return string
	 */
	public function getName() {
		return $this->name;
	}

	/**
	 * @param string $name
	 * @return Address
	 */
	public function setName($name) {
		$this->name = $name;
		return $this;
	}

	/**
	 * @return int
	 */
	public function getCountryId() {
		return $this->countryId;
	}

	/**
	 * @param int $countryId
	 * @return Address
	 */
	public function setCountryId($countryId) {
		$this->countryId = $countryId;
		return $this;
	}

	/**
	 * @return string
	 */
	public function getAddress() {
		return $this->address;
	}

	/**
	 * @param string $address
	 * @return Address
	 */
	public function setAddress($address) {
		$this->address = $address;
		return $this;
	}
	
	/**
	 * @return int
	 */
	public function getNumber() {
		return $this->number;
	}

	/**
	 * @param int $number
	 * @return Address
	 */
	public function setNumber($number) {
		$this->number = $number;
		return $this;
	}
	
	/**
	 * @return int
	 */
	public function getPostcode() {
		return $this->postcode;
	}

	/**
	 * @param int $postcode
	 * @return Address
	 */
	public function setPostcode($postcode) {
		$this->postcode = $postcode;
		return $this;
	}
	
	/**
	 * @return int
	 */
	public function getStatus() {
		return $this->status;
	}

	/**
	 * @param int $status
	 * @return Address
	 */
	public function setStatus($status) {
		$this->status = $status;
		return $this;
	}
	
	/**
	 * @return datetime
	 */
	public function getDateAdded() {
		return $this->dateAdded;
	}

	/**
	 * @param datetime $dateAdded
	 * @return Address
	 */
	public function setDateAdded($dateAdded) {
		$this->dateAdded = $dateAdded;
		return $this;
	}
}